package org.geom.curve.helix;

import org.geom.Maths;
import org.geom.Point3D;
import org.geom.Vector3D;
import org.geom.curve.Curve;

public class Helix extends Curve{

	public static final String R = "r";
	public static final String K = "k";

	public static float arc = 0.8f; //
	
	//---------------------------------------------------------------------- constructor
	public Helix() {
		super();
	}
	
	//---------------------------------------------------------------------- curve properties
	private float r = 40;
	public float getR() {
		return r;
	}
	public void setR(float r) {
		this.r = r;
	}
	
	private float k = 30;
	public float getK() {
		return k;
	}
	public void setK(float k) {
		this.k = k;
	}
	
	private float maxt = 5;
	public void setMaxt(float maxt) {
		this.maxt = maxt;
	}
	public float getMaxt() {
		return maxt;
	}


	//------------------------------------------------ abstract implementation
	public Point3D sample(float t) {
		Point3D p = new Point3D();
		
		p.x = r * Maths.cos(t);
		p.y = r * Maths.sin(t);
		p.z = k * t;
		
		return p;		
	}
		
	@Override
	public Vector3D derivateI(float t)  {
		Vector3D p = new Vector3D();
		
		p.x = r * -Maths.sin(t);
		p.y = r * Maths.cos(t);
		p.z = k;
		
		return p;
	}
	
	@Override
	public Vector3D derivateII(float t) {  
		Vector3D p = new Vector3D();
		
		p.x = r * -Maths.cos(t);
		p.y = r * -Maths.sin(t);
		p.z = k;
		
		return p;
	}

	@Override
	public float getArc() {
		float totallength = maxt * Maths.TWO_PI;
		return totallength/((float)length-1);
	}

}
